Interface ICollection<T>

The simplest interface of a main stream generic collection with lookup, insertion and removal operations.

Implements

IEnumerable<T>, System.Collections.IEnumerable, System.IFormattable, System.ICloneable, ICollectionValue<T>, IExtensible<T>, IShowable

Implemented by

ArrayList<T>, GuardedCollection<T>, GuardedIndexedSorted<T>, GuardedList<T>, GuardedSequenced<T>, GuardedSorted<T>, HashBag<T>, HashedArrayList<T>, HashedLinkedList<T>, HashSet<T>, LinkedList<T>, SortedArray<T>, TreeBag<T>, TreeSet<T>, WrappedArray<T>

Super

IIndexed<T>, IIndexedSorted<T>, IList<T>, IPersistentSorted<T>, ISequenced<T>, ISorted<T>

Property overview

ContainsSpeed

Method overview

Clear() ,
Contains(T item) ,
ContainsAll<U>(IEnumerable<U> items) ,
ContainsCount(T item) ,
Find(ref T item) ,
FindOrAdd(ref T item) ,
GetUnsequencedHashCode() ,
ItemMultiplicities() ,
Remove(T item) ,
Remove(T item, out T removeditem) ,
RemoveAll<U>(IEnumerable<U> items) ,
RemoveAllCopies(T item) ,
RetainAll<U>(IEnumerable<U> items) ,
UniqueItems() ,
UnsequencedEquals(ICollection<T> otherCollection) ,
Update(T item) ,
Update(T item, out T olditem) ,
UpdateOrAdd(T item) ,
UpdateOrAdd(T item, out T olditem)

Property details

A Speed ContainsSpeedAccess: Read-Only

Value:A characterization of the speed of lookup operations (Contains() etc.) of the implementation of this collection.

The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant).

See Speed for the set of symbols.

Method details

A void Clear() Remove all items from this collection.
A bool Contains(T item) Check if this collection contains (an item equivalent to according to the itemequalityComparer) a particular value.
Returns:True if the items is in this collection.
Parameters:
item:The value to check for.
A bool ContainsAll<U>(IEnumerable<U> items) Check whether this collection contains all the values in another collection. If this collection has bag semantics (AllowsDuplicates==true) the check is made with respect to multiplicities, else multiplicities are not taken into account.
Type parameters:
U
Constraints:
U : T
Returns:True if all values in itemsis in this collection.
Parameters:
items:The
A int ContainsCount(T item) Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection.
Returns:The number of copies found.
Parameters:
item:The value to count.
A bool Find(ref T item) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found.
Returns:True if the items is in this collection.
Parameters:
item:The value to look for.
A bool FindOrAdd(ref T item) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. Else, add the item to the collection.
Returns:True if the item was found (hence not added).
Parameters:
item:The value to look for.
A int GetUnsequencedHashCode() The unordered collection hashcode is defined as the sum of h(hashcode(item)) over the items of the collection, where the function h is a function from int to int of the form t -> (a0*t+b0)^(a1*t+b1)^(a2*t+b2), where the ax and bx are the same for all collection classes.

The current implementation uses fixed values for the ax and bx, specified as constants in the code.

Returns:The unordered hashcode of this collection.
A ICollectionValue<KeyValuePair<T,int>> ItemMultiplicities()
Returns:
A bool Remove(T item) Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed.
Returns:True if the item was found (and removed).
Parameters:
item:The value to remove.
A bool Remove(T item, out T removeditem) Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument.
Returns:True if the item was found (and removed).
Parameters:
item:The value to remove.
removeditem:The value removed if any.
A void RemoveAll<U>(IEnumerable<U> items) Remove all items in another collection from this one. If this collection has bag semantics, take multiplicities into account.
Type parameters:
U
Constraints:
U : T
Parameters:
items:The items to remove.
A void RemoveAllCopies(T item) Remove all items equivalent to a given value.
Parameters:
item:The value to remove.
A void RetainAll<U>(IEnumerable<U> items) Remove all items not in some other collection from this one. If this collection has bag semantics, take multiplicities into account.
Type parameters:
U
Constraints:
U : T
Parameters:
items:The items to retain.
A ICollectionValue<T> UniqueItems()
Returns:
A bool UnsequencedEquals(ICollection<T> otherCollection) Compare the contents of this collection to another one without regards to the sequence order. The comparison will use this collection's itemequalityComparer to compare individual items.
Returns:True if this collection and that contains the same items.
Parameters:
otherCollection:The collection to compare to.
A bool Update(T item) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one.
Returns:True if the item was found and hence updated.
Parameters:
item:Value to update.
A bool Update(T item, out T olditem) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one.
Returns:True if the item was found and hence updated.
Parameters:
item:Value to update.
olditem:On output the olditem, if found.
A bool UpdateOrAdd(T item) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection.
Returns:True if the item was found and updated (hence not added).
Parameters:
item:Value to add or update.
A bool UpdateOrAdd(T item, out T olditem) Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection.
Returns:True if the item was found and updated (hence not added).
Parameters:
item:Value to add or update.
olditem:On output the olditem, if found.